<!DOCTYPE html>
<html>
	<head>
		
		<meta charset="utf-8" />
		<title>鉴宝</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes"/>
		<meta name="format-detection" content="telephone=no"  />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge，chrome=1">
		<link rel="stylesheet" href="css/css.css" />
		<script type="text/javascript" src="js/jquery-1.7.1.min.js" ></script>
		<script type="text/javascript" src="js/all.js" ></script>
        <script type="text/javascript" src="js/jquery-2.1.3.min.js" ></script>
        <script type="text/javascript" src="js/localResizeIMG2.js" ></script>
        <script type="text/javascript" src="js/mobileBUGFix.mini.js" ></script>
    </head>
	<body style="background:url(img/user_banner.jpg) no-repeat center center;">
		<div class="wapper">
			<header>
				<div class="goback"><a href=""><img src="img/back.png" /> <span>返回</span></a></div>
				<div class="midtit">个人基本信息</div>
				<div class="morshar"><a href="">...</a></div>
			</header>
			
            
            
            <section class="U_sj">
                     <div class="twoelement">
						<p class="fixedelement2">头像</p>
					    <p class="changeelement boxtext-r">
					    					    <span class="U_ttx"><img class="peosonalheaimg" src="img/J3.png" alt="头像"></span>
					    
					    <a><input class="smallimginput"></a></p>
						<p class="changeelement  boxtext-r phoneaddimg ddd2">
							<!--<img width="100%" height="100%" class="dtupi" src="img/J3.png" alt="">--><span class="xg">修改</span><input type="file" id="doc" name="Member[head]">
						</p>
						<ul class="clearfix" id="dd">
										</ul>
					</div>
            </section>
<script>

    (function () {
        var viewImg = $("#dd");
        var imgurl = '';
        var imgcount = 0;
        $('#doc').localResizeIMG({
            width: 80,
            quality: 1,
            success: function (result) {
				console.log($(this));
                var status = true;
                if (result.height > 100) {
                    status = false;
                    alert("照片最大高度不超过1600像素");
                }
                
                if (status) {
                    viewImg.append('<li><span class="pic_time"><span class="p_img"></span><em>50%</em></span></li>');
                    viewImg.find("li:last-child").html('<span class="del"></span><img class="wh60" src="' + result.base64 + '"/><input type="hidden" class="cstp" id="doc' + imgcount + '" name="Member[head][]" value="' + result.clearBase64 + '">');
					 var submitData={
						base64_string:result.clearBase64, 
						//'crsrf':'RmM5Q0RMaUEsUVAoAmEYBA0FaRYDfVEDNTlKKTQkIy4TLl4wdHgIKw==',
					}; 
					$(".peosonalheaimg").remove();
					$.ajax({
					   type: "POST",
					   url: "/images/nickname.php",
					   data: submitData,
					   dataType:"json",
					   success: function(data){
							if(data==0){
								$('#tip-error span').html('服务器繁忙，稍后重试');
								$('#tip-error').show();
								setTimeout(function(){
									$('#tip-error').fadeOut(500);
								},1000);
							}else if(data==1){
								$('#tip-error span').html('头像成功上传');
								$('#tip-error').show();
								setTimeout(function(){
									$('#tip-error').fadeOut(500);
								},1000);
							}
					   }, 
						error:function(){ //上传失败 
						   $('#tip-error span').html('服务器繁忙，稍后重试');
							$('#tip-error').show();
							setTimeout(function(){
								$('#tip-error').fadeOut(500);
							},1000);
						}
					});
                    $(".del").on("click",function(){
                        $(this).parent('li').remove();
                        $("#doc").show();
                    });
                    imgcount++;
                }
            },
			error:function(res) {
				$('#tip-error span').html('文件不合法');
					$('#tip-error').show();
					setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
			}
        });
    })();
		$(".formok-btn").click(function(event){
			event.preventDefault();
			var editinformation=$("textarea[name='editinformation']").val();
			if(editinformation.length > 14){
				$('#tip-error span').html('个签长度不符合规范');
				$('#tip-error').show();
				setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
				$("textarea[name='editinformation']").focus();
			}else{
				$.ajax({
					   type: "POST",
					   url: "/images/nickname.php",
					   data: {'editinformation':editinformation},
					   dataType:"json",
					   success: function(data){
							if(data==0){
								$('#tip-error span').html('服务器繁忙，稍后重试');
								$('#tip-error').show();
								setTimeout(function(){
									$('#tip-error').fadeOut(500);
								},1000);
							}else if(data==1){
								$('#tip-error span').html('修改成功');
								$('#tip-error').show();
								location.href='/center/personalcenter';
								setTimeout(function(){
									$('#tip-error').fadeOut(500);
								},1000);
							}
					   }, 
						error:function(){ //上传失败 
						   $('#tip-error span').html('服务器繁忙，稍后重试');
							$('#tip-error').show();
							setTimeout(function(){
								$('#tip-error').fadeOut(500);
							},1000);
						}
					});
			}
		});
		$(".bodyA").hide();

</script>
            
            
            
            
            
            <section class="U_sj" style="margin-top:0.2rem;">
                     <!--<a class="U_a" href="#"><div><span>会员昵称</span><span style="float:right">会员昵称</span></div></a>-->
                     <div class="twoelement">
						<p class="U_a"><span>昵称</span></p>
					    <p class="changeelement boxtext-r text-r" style=" float:right;"><a><input class="changeelement" type="text" id="username" name="username" placeholder="输入您的昵称" value="Ti4sad253"></a></p>
					</div>
            </section>
            
            
            <section class="U_sj" style="margin-top:0.2rem;">
                     <a class="U_a"><div><span>手机号</span><span class="S_cli" style="float:right">136****1234</span></div></a>
            <script>
			     $(document).ready(function(){
					   $(".S_cli").click(function(){
                             alert("手机号不能修改")
                        });
					 });  
            </script>
            </section>
            
            
            <section class="U_sj" style="margin-top:0.2rem;">
                     <a class="U_a" href="#"><div><span>收货地址</span><span style="float:right"><img class="U_san" src="img/U_san.png"></span></div></a>
            </section>
            
            
            <p id="tip-error" style="display: none;"><span>昵称修改成功</span></p>
            
            
            
<script>

	$(document).ready(function(){
		$('input[name=username]').change(function() { 
			var name=$("input[name='username']").val();
			 if(name.length > 10 || name.length==0){
				$('#tip-error span').html('昵称长度不合法');
				$('#tip-error').show();
				setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
				$("input[name='username']").focus();
			}else{
				$.ajax({
					   type: "POST",
					   url: "/images/nickname.php",
					   data: {'name':name},
					   dataType:"json",
					   success: function(data){
						   console.log(data);
							if(data==0){
								$('#tip-error span').html('服务器繁忙，稍后重试');
								console.log(data);
								$('#tip-error').show();
								setTimeout(function(){
									$('#tip-error').fadeOut(500);
								},1000);
							}else if(data==1){
								$('#tip-error span').html('昵称修改成功');
								$('#tip-error').show();
								setTimeout(function(){
									$('#tip-error').fadeOut(500);
								},1000);
							}
					   }, 
						error:function(){
							alert(2); //上传失败 
						   $('#tip-error span').html('服务器繁忙，稍后重试');
							$('#tip-error').show();
							setTimeout(function(){
								$('#tip-error').fadeOut(500);
							},1000);
						}
					});
			}
			
		});
		
		
		
		
		
		
		
		
		
		
		$(".formok-btn").click(function(event){
			event.preventDefault();
			// var name=$("input[name='username']").val();
			// var sex=$("select[name='sex']").val();
			// var email=$("input[name='email']").val();
			var editinformation=$("textarea[name='editinformation']").val();
			if(editinformation.length > 24){
				$('#tip-error span').html('个签长度不符合规范');
				$('#tip-error').show();
				setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
				$("textarea[name='editinformation']").focus();
			}else{
				$("#post").submit();
			}
			return;
			reg=/(^[1][358][0-9]{9}$)/;
			if(!name){
				$('#tip-error span').html('请输入您的昵称');
				$('#tip-error').show();
				setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
				$("input[name='emailorphone']").focus();
			}else if(name.length > 10){
				$('#tip-error span').html('昵称过长');
				$('#tip-error').show();
				setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
				$("input[name='emailorphone']").focus();
			}else{
				$(this).parents("form").submit();
			}
			
			
			
			
			
			if(editinformation.length > 14){
				$('#tip-error span').html('个签长度不符合规范');
				$('#tip-error').show();
				setTimeout(function(){
					$('#tip-error').fadeOut(500);
				},1000);
				$("textarea[name='editinformation']").focus();
			}else{
				$("#post").submit();
			}
			
			
			
			
		});
		$(".bodyA").hide();
	})
</script>

			<footer>
				<ul>
					<li><a href="">
						<p class="icoimg"><img src="img/home.png"  /></p>
						<p>首页</p>
					</a>
					</li>
					<li><a href="">
						<p class="icoimg"><img src="img/zj.png" /></p>
						<p>专家</p>
						</a>
					</li>
					<li><a href="">
						<p class="icoimg"><img src="img/yyclass.png" /></p>
						<p>语音课堂</p>
						</a>
					</li>
				</ul>
			</footer>
		</div>
	</body>
</html>
